<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,maximum-scale=1.0" />
    <title>${r"<#"}if entity.${keyProperties}??>编辑${r"<#"}else>新增${r"</#"}if>${describe}</title>
    ${r"<#"}include "/view/admin/head.html"/>
<#if hasFile==1>
    <script type="text/javascript" src="${r"${base}"}/jstool/bootstrap-fileinput/js/fileinput.js"></script>
    <script type="text/javascript" src="${r"${base}"}/jstool/bootstrap-fileinput/js/locals/zh.js"></script>
    <link rel="stylesheet" type="text/css" href="${r"${base}"}/jstool/bootstrap-fileinput/css/fileinput.min.css" />
</#if>
<#if hasSwitch==1>
    <script type="text/javascript" src="${r"${base}"}/jstool/bootstrap-switch/bootstrap-switch.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${r"${base}"}/jstool/bootstrap-switch/bootstrap-switch.min.css" />
</#if>
<#if hasDate==1>
    <script type="text/javascript" src="${r"${base}"}/jstool/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
    <script type="text/javascript" src="${r"${base}"}/jstool/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    <link rel="stylesheet" type="text/css" href="${r"${base}"}/jstool/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />
</#if>
<#if hasSelect==1>
    <script type="text/javascript" src="${r"${base}"}/jstool/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
    <script type="text/javascript" src="${r"${base}"}/jstool/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    <link rel="stylesheet" type="text/css" href="${r"${base}"}/jstool/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />
</#if>


    <script type="text/javascript" src="${r"${base}"}/jstool/bootstrap-validator-0.5.3/js/bootstrapValidator.min.js"></script>
    <script type="text/javascript" src="${r"${base}"}/jstool/bootstrap-validator-0.5.3/lang/zh_CN.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${r"${base}"}/jstool/bootstrap-validator-0.5.3/css/bootstrapValidator.min.css" />


    <style type="text/css">
        .list-path {
            height: 50px;
            line-height: 50px;
            background-color: #9acfea;
        }

        .table-class {
            width: 90%;
            text-align: center;
            border: 1px solid #afd9ee;
            margin: 0 auto;
            margin-top: 50px;
        }

        table th {
            width: 20%;
            background-color: #d9edf7;
            text-align: right;
        }

        table td {
            width: 20%;
            text-align: left;
        }


    </style>
    <script type="text/javascript">

        $(function(){
            //初始化
        <#list columnList as var>
            <#if 'file'==var.inputType>
                $('#${var.properties}').fileinput({
                    language: 'zh', //设置语言
                    allowedFileExtensions : ['jpg', 'png','gif'],//接收的文件后缀
                    showUpload: false, //是否显示上传按钮
                    showCaption: false,//是否显示标题
                    browseClass: "btn btn-primary", //按钮样式
                    previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
                });
            <#elseif 'date'==var.inputType>
                $('#${var.properties}').datetimepicker({language: 'zh-CN' });
            <#elseif 'switch'==var.inputType>
                <#list listSwitch as s>
                    <#if s.name==var.properties>
                    $('[name="${var.properties}cb"]').bootstrapSwitch({
                        <#list s.switch as st>
                            <#if st.value==1>
                                onText:"${st.name}",
                            <#elseif st.value==0>
                                offText:"${st.name}",
                            </#if>
                        </#list>
                        onColor:"success",
                        offColor:"info",
                        size:"small",
                        onSwitchChange:function(event,state){
                            if(state==true){
                                $(this).val("1");
                                $('[name="${var.properties}"]').val("1");
                            }else{
                                $(this).val("0");
                                $('[name="${var.properties}"]').val("0");
                            }
                        }
                    });
                    </#if>
                </#list>
            <#else>

            </#if>
        </#list>



            $('#${simpleClassname}Form').bootstrapValidator({
                message: 'This value is not valid',
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
            <#assign num=0>
            <#list columnList as var>

                <#if 'text'==var.inputType>
                    <#if num==1>,</#if>
                    <#assign num=1>
                ${var.properties}:{
                    message: '输入${var.describe}出错',
                    validators:{
                        notEmpty: {
                            message: '${var.describe}不能为空'
                        },
                        stringLength:{
                            max: ${var.length},
                            message: '${var.describe}不能超过 ${var.length}个字符'
                        }
                    }
                }
                <#elseif 'int'==var.inputType>
                    <#if num==1>,</#if>
                    <#assign num=1>
                ${var.properties}:{
                    message: '输入${var.describe}出错',
                    validators:{
                        notEmpty: {
                            message: '${var.describe}不能为空'
                        },
                        stringLength:{
                            max: ${var.length},
                            message: '${var.describe}不能超过 ${var.length}个字符'
                        },
                        regexp: {
                            regexp: /^[0-9]+$/,
                                    message:'${var.describe}只能是数字'
                        }
                    }
                }
                <#elseif 'decimal'==var.inputType>
                    <#if num==1>,</#if>
                    <#assign num=1>
                ${var.properties}:{
                        message: '输入${var.describe}出错',
                        validators:{
                            notEmpty: {
                                message: '${var.describe}不能为空'
                            },
                            stringLength:{
                                max: ${var.length},
                                message: '${var.describe}不能超过 ${var.length}个字符'
                            },
                            regexp: {
                                regexp: /^[1-9][0-9]*$|^[1-9][0-9]*\.[0-9]{1,2}$|^0\.[0-9]{1,2}$/,
                                message:'${var.describe}只能是金额'
                            }
                        }
                    }

                    <#else>

                </#if>
            </#list>
                }
            });


        });

    </script>
</head>
<body>
${r"<#"}include "/view/admin/listnav.html"/>


<div class="table-class">
    ${r"<#"}include "/view/admin/opermsg.html"/>
    <form id="${simpleClassname}Form" action="${r"${base}"}/${simpleClassname}/save.do"
    <#if hasFile==1> method="post" enctype="multipart/form-data" </#if> >
    <table class="table table-bordered">
    <#assign num1=0>
        <#list columnList as var>

            <#if 'hidden'==var.inputType>
                        <input type="hidden" style="display: none" name="${var.properties}" value="${r"${"}entity.${var.properties}!${r"}"}"/>

            <#elseif 'text'==var.inputType||'int'==var.inputType||'decimal'==var.inputType>
                <#if num1%2==0><tr></#if>
                <th>${var.describe}</th>
                <td>
                    <div class="form-group">
                        <input type="text" class="form-control" id="${var.properties}" name="${var.properties}" placeholder="请输入${var.describe}" value="${r"${"}entity.${var.properties}!${r"}"}">
                    </div>
                </td>
                <#if (num1-1)%2==0||(var_index+1)==columnList?size></tr></#if>
                <#assign num1=num1+1>
            <#elseif 'file'==var.inputType>
                <#if num1%2==0><tr></#if>
                <th>${var.describe}</th>
                <td>
            ${r"<#"}if entity.${var.properties}??>
                        <img src="${r"${base}${"}entity.${var.properties}!${r"}"}" height="100px">
            ${r"</#"}if>

                    <input type="file" class="form-control" id="${var.properties}" name="file${var.propertiesUp}" >
                </td>
                <#if (num1-1)%2==0||(var_index+1)==columnList?size></tr></#if>
                <#assign num1=num1+1>
            <#elseif 'date'==var.inputType>
                <#if num1%2==0><tr></#if>
                <th>${var.describe}</th>
                <td>
                    <input type="text" class="form-control" value="${r"<#if "}(entity.${var.properties})?? >${r"${"}entity.${var.properties}?string('yyyy-MM-dd HH:mm:ss')${r"}</#if>"}" id="${var.properties}" name="${var.properties}" data-date-format="yyyy-mm-dd hh:ii:ss">
                </td>
                <#if (num1-1)%2==0||(var_index+1)==columnList?size></tr></#if>
                <#assign num1=num1+1>
            <#elseif 'switch'==var.inputType>
                <#if num1%2==0><tr></#if>
                <th>${var.describe}</th>
                <td>
                <input name="${var.properties}" type="hidden" value="${r"<#if"} entity.${var.properties}??>${r"${"}entity.${var.properties}${r"}<#else>0</#if>"}"/>
                <input name="${var.properties}cb" type="checkbox"  data-size="small"
                       ${r"<#"}if entity.${var.properties}??>
                <#list listSwitch as s>
                    <#if s.name==var.properties>
                        <#list s.switch as st>
                        ${r"<#"}if ${st.value}==entity.${var.properties}>
                        <#if st.value==1>
                            checked="checked"
                        </#if>
                            value="${st.value}"${r"</#"}if>
                        </#list>
                    </#if>
                </#list>
                ${r"</#"}if>/>
                </td>
                <#if (num1-1)%2==0||(var_index+1)==columnList?size></tr></#if>
                <#assign num1=num1+1>


            <#elseif 'select'==var.inputType>
                <#if num1%2==0><tr></#if>
                <th>${var.describe}</th>
                <td>
                    <div class="form-group">
                        <select id="${var.properties}" name="${var.properties}"
                            <#if 'int'==var.inputCode||'str'==var.inputCode>
                                class="form-control selectpicker"   data-live-search="true"
                            <#else>
                                class="form-control"
                            </#if>
                        >
                            <option value="">请选择${var.describe}</option>
                            <#list listSelect as s>
                                <#if s.name==var.properties>
                                    <#if 'int'==var.inputCode || 'str'==var.inputCode>
                                    ${r"<#list"} list${var.propertiesUp} as lv>
                                        <option value="${r"${"}lv.value!${r"}"}"
                                        ${r"<#if"} lv.value??&&entity.${var.properties}??&&entity.${var.properties} == lv.value >
                                            selected="selected"
                                        ${r"</#if>"}
                                            >${r"${"}lv.name!${r"}"}</option>
                                    ${r"</#list>"}
                                    <#else>
                                        <#list s.select as st>
                                            <option value="${st.value}" ${r"<#"}if entity.${var.properties}??&&${st.value} == entity.${var.properties}>selected="selected"${r"</#"}if>>${st.name}</option>

                                        </#list>
                                    </#if>

                                </#if>
                            </#list>
                        </select>
                    </div>
                </td>
                <#if (num1-1)%2==0||(var_index+1)==columnList?size></tr></#if>
                <#assign num1=num1+1>
            </#if>
        </#list>


        <tr>
            <td colspan="4" width="100%" style="text-align: center;">
                <input type="submit" class="btn btn-success " value="保存"/>
                <span style="width: 20px;">&nbsp;</span>
                <a class="btn btn-danger " href="javascript:window.history.go(-1)">
                   </span>返回</a>
            </td>
        </tr>

    </table>
</form>




</div>

<script type="text/javascript">

</script>


</body>
</html>
